<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="location">当前位置：招聘实施管理 > 面试批次管理</div>
<div id="Content">
    <div class="tabbar">
        <a href="/Do/MS/msbatch" id="btn_msbatch">面试批次</a>
        <a id="btn_msbatchuser">批次人员</a>
        <a class="current">批次附件</a>
    </div>
    <!-- 筛选条件 -->
    <div id="searchbox">
        <form id="searchform">
            <table class="treeTable searchform">
                <thead>
                <tr>
                    <td width="60">批次号：</td>
                    <td width="400">
                        <div><input type="text" name="mspch" id="mspch"></div>
                    </td>
                    <td width="60">附件名称：</td>
                    <td width="200">
                        <div><input type="text" name="filename"></div>
                    </td>

                    <td width="150" style="min-width: 150px">
                        <div class="toolbars">
                            <a id="searchbtn">
                                <em class="ico16 search_16"></em>
                                <span class="menu_span" title="查询">查询</span>
                            </a>
                        </div>
                    </td>
                    <td width="150" style="min-width: 150px">
                        <div class="toolbars">
                            <a id="clearbtn">
                                <em class="ico16 del_16"></em>
                                <span class="menu_span" title="清除">清除</span>
                            </a>
                        </div>
                    </td>
                </tr>

                </thead>
            </table>
        </form>
    </div>
    <div class="toolbars">
        <%--        <button type="button" class="save" id="btn_upload">上传附件</button>--%>
        <%--        <button type="button" class="card" id="btn_down">下载附件</button>--%>
        <div class="toolbars"  style="height:30px;white-space:nowrap;width:auto;margin-left: 20px; display: inline-block">
            <a id="btn_upload">
                <em class="ico16 save_up_16"></em>
                <span class="menu_span" title="上传附件">上传附件</span>
            </a>
        </div>
        <div class="toolbars" style="height:30px;white-space:nowrap;width:auto;margin-left: 20px; display: inline-block">
            <a id="btn_down">
                <em class="ico16 download_16"></em>
                <span class="menu_span" title="下载附件">下载附件</span>
            </a>
        </div>
    </div>
    <%--    <table class="treeTable" id="tablelist">--%>
    <%--        <thead>--%>
    <%--        <tr>--%>
    <%--            <td width="20"><input type="checkbox" class="allcheckbox" title="选择全部/取消全选"/></td>--%>
    <%--            <td width="30">序号</td>--%>
    <%--            <td width="200">附件名称</td>--%>
    <%--            <td width="80">附件大小</td>--%>
    <%--            <td width="80">上传时间</td>--%>
    <%--            <td width="80">上传人</td>--%>
    <%--            <td width="160">面试批次</td>--%>
    <%--            <td style="display: none">方案ID</td>--%>
    <%--            <td width="150">方案名称</td>--%>
    <%--            <td style="display: none">岗位ID</td>--%>
    <%--            <td width="150">面试岗位</td>--%>
    <%--            <td width="60">操作</td>--%>
    <%--        </tr>--%>
    <%--        </thead>--%>
    <%--        <tbody id="result"></tbody>--%>
    <%--    </table>--%>
    <%--    <div id="page"></div>--%>
</div>
<div style="overflow:hidden;">
    <div id="div_table" style="bottom: 0px">
        <table class="layui-hide" id="table" lay-filter="msenclosureTable"></table>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        layui.use('table', () => {
            let table = layui.table;
            table.render({
                id: 'table'
                , elem: '#table'
                , height: 'full'
                , url: '/Do/MS/queryMsBatchFileJson?' + $("#searchform").serialize()//数据接口
                , title: '用户表'
                , page: true //开启分页
                , cols: [[ //表头
                    {type: 'checkbox', fixed: 'left', width: 50}
                    , {type: 'numbers', title: '序号', width: '9%', sort: true}
                    , {field: '1', title: '附件名称', width: '9%', sort: true}
                    , {field: '2', title: '附件大小', width: '9%', sort: true}
                    , {field: '3', title: '上传时间', width: '9%', sort: true}
                    , {field: '4', title: '上传人', width: '9%', sort: true}
                    , {field: '5', title: '面试批次', width: '9%', sort: true}
                    , {field: '7', title: '方案名称', width: '9%', sort: true}
                    , {field: '9', title: '面试岗位', width: '9%', sort: true}
                    , {
                        field: '10', title: '操作', width: '9%', templet: (d) => {
                            return '<a onClick=showDetial(\'' + d[0].toString() + '\') style=\'color:#2b72dc;\'>详情</a>' +
                                '<a onClick=downfile(\'' + d[0].toString() + '\') style=\'color:#2b72dc;\'>下载</a>';
                        }
                    }
                ]]
            });
            reload = () => {
                table.reload('table');
            }
            document.tablereload = reload;
            $("#searchbtn").on('click', () => {
                table.reload('table', {
                    url: '/Do/MS/queryMsBatchFileJson?' + $("#searchform").serialize()//数据接口
                    , page: {
                        curr: 1
                    }
                })
            })
        });

        // $('#searchbtn').click(function () {
        //     getList();
        // });
        var mspch = getQueryString("mspch");
        var pname = getQueryString("pname");
        var jname = getQueryString("jname");
        var jid = getQueryString("jid");
        var pid = getQueryString("pid");
        $("#mspch").val(mspch);
        if (!!!mspch) {
            layer.msg('请先选择面试批次!', {icon: 5, time: 2000}, function () {
                location.href = "/Do/MS/msbatch";
            });
        } else {
            $('#searchbtn').click();
        }
        $('#btn_msenclosure').click(function () {
            $('#btn_msenclosure').show();
            location.href = "/Do/MS/msbatchuser?mspch=" + mspch + "&pid=" + pid + "&pname=" + pname + "&jid=" + jid + "&jname=" + jname;
        });

        $('#btn_upload').click(function () {
            openLayer('导入面试成绩', '/Do/MS/msenclosureimport?mspch=' + mspch + '&pid=' + pid + '&pname=' + pname + '&jid=' + jid + '&jname=' + jname, '70%', '50%');
        })

        $('#btn_down').click(function () {
            let chosendata = layui.table.checkStatus('table').data;

            // var checkRows = $('.allcheckbox').data('checkIds');
            if (chosendata.length > 1) {
                layer.msg('只能选择一条信息', {icon: 7, time: 2000});
                return;
            } else if (chosendata.length === 0) {
                layer.msg('请选择一条信息', {icon: 7, time: 2000});
                return;
            }
            let id =  "id=" + chosendata[0][0];
            {
                // $(checkRows).each(function (index, itme) {
                //     ids += itme.replace('cb_', '') + ",";
                // });
                // ids = ids.substring(0, ids.length - 1);
                $.ajax({
                    url: '/Do/MS/MsEnclosureDown?' + id,
                    dataType: "json",
                    type: "POST",
                    success: function (data) {
                        if (data.state) {
                            layer.msg(data.message, {icon: 6, time: 1000}, function () {
                                location.href = data.url;
                            });
                        } else {
                            if (!!data.message) {
                                layer.msg(data.message, {icon: 5, time: 1000});
                            } else {
                                layer.msg(data.message, {icon: 5, time: 1000});
                            }
                        }
                    }
                });
                location.href = "/Do/MS/MsEnclosureDown?" + id;
            }
        });

    });

    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = decodeURI(window.location.search).substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    function getList() {
        $('#page').myPagination({
            cssStyle: "pagination",
            singleCheck: true,
            saveChecked: true,
            ajax: {
                on: true,
                param: $("#searchform").serialize(),
                url: '/Do/MS/queryMsBatchFile',
                dataType: 'html',
                callback: function (data) {
                    $('#result').html(data);
                }
            }
        });
    }
</script>
</body>
</html>